
///代码清单 7-6
///lib/code7/provider/demo1/time_counter_model.dart
import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';
class TimeCounterModel with ChangeNotifier {

  String _formatTime="00:00:00";

  void getCurrentTime() {
    ///获取当前的时间
    DateTime dateTime= DateTime.now();
    ///格式化时间 import 'package:intl/intl.dart';
    ///需要添加 intl 依赖
    _formatTime = DateFormat("HH:mm:ss").format(dateTime);
    notifyListeners();//2
  }

  get formatTime => _formatTime;//3
}